<!DOCTYPE html>
<html>
<head>
    {include file='public/meta'/}


</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section id="content">
    {include file='public/left'/}

    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgr15 mgl15">
            <ol class="breadcrumb">
                <li>当前位置是:</li>
                <li>
                    <a href="{:url('cardjc/cardjclist',['card_id'=>$card['card_id']])}">会员计次卡</a>
                </li>
                <li class="active" style="color: #02b87f;">会员计次卡详情</li>
            </ol>
        </div>
        <div class="panel mgr15 mgl15">
            <div class="form-horizontal adminex-form" >
                <div class="panel-heading addCharts" style="background:#ededed;">
                    会员计次卡内容
                </div>

                <div class="panel-body">
                    <form  class="form-horizontal" role="form" action='' method="post" id="forms">
                        <input type="hidden" name="id" value="{$info.id}">
                        <input type="hidden" name="card_id" value="{$info.card_id}">
                
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">名称：</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name='title' id="title" value="{$info.title}" placeholder="" required="required">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">价格：</label>
                            <div class="col-sm-3">
                                <input type="number" class="form-control" name='price' id="price"  step="0.01" value="{$info.price}" placeholder="" required="required">
                            </div>
                            <label class="control-label">元</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">次数：</label>
                            <div class="col-sm-3">
                                <input type="number" class="form-control" name='pay_num' id="pay_num"  value="{$info.pay_num}" placeholder="" required="required">
                            </div>
                            <label class="control-label">次</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">有效期：</label>
                            <div class="col-sm-3">
                                <input type="number" class="form-control" placeholder="" id="term_of" name='term_of' value="{$info.term_of}" required="required">
                                <div class="r-desc ng-binding ng-scope">购买后有效天数。</div>

                            </div>
                            <label class="control-label">天</label>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">核销密码：</label>
                            <div class="col-sm-3">
                                <input type="number" class="form-control"  name='hx_pass' value="" placeholder="" >
                                <div class="r-desc ng-binding ng-scope">建议会员计次卡审核密码为6个数字。</div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">适用门店：</label>
                            <div class="col-sm-10">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" name="store[]" value="0" onclick="check(this);">全部门店
                                    </label>
                                    {volist name="machlist" id="search"}
                                    <label>
                                        <input type="checkbox" name="store[]" value="{$search['id']}" class="checkmid">{$search.merchant}
                                    </label>

                                    {/volist}
                                </div>
                            </div>
                        </div>

                        <div class="panel-footer ">
                            <button type="button" class="btn btn-primary" id="creatcards-btn">修改</button>
                        </div>
                    </form>
                </div>

            </div>
        </div>
        {include file='public/footer'/}
    </div>
    <!--获取门店列表-->
</section>
</body>
<!--一级和二级类目选择-->
<script>
    function check(obj){

        if ($(obj).is(":checked")) {

            $(obj).parent().siblings().find("input:checkbox").attr("checked", true);

        } else {

            $(obj).parent().siblings().find("input:checkbox").attr("checked", false);
        }
    }
</script>
<script>
    $(function(){
//        页面加载完毕 门店显示为选中状态 开始
        var mid="{$storelist}";

        var checkbox = $(".checkmid").length;
        var arr = mid.split(",");
        for(var j= 0 ;j<arr.length;j++){
            for(var i=0;i<checkbox;i++){
                var checkval= $(".checkmid").eq(i).val();
                if(arr[j]==checkval){
                    $(".checkmid").eq(i).attr("checked","checked")
                }
            }
        }

//        页面加载完毕 门店显示为选中状态 结束
        $('.is_tk').on('switch-change',function (e, data) {
            var $el = $(data.el),value = data.value;
            if(value==true){
                $("#is_tk").val(1);
            }else if(value==false){
                $("#is_tk").val(0);
            }

        });
    })
</script>
<script>
    $("#creatcards-btn").click(function() {
        var pay_num=$("#pay_num").val();
        var term_of=$("#term_of").val();
        if(!(/(^[1-9]\d*$)/.test(pay_num))){
            layer.alert("次数请填写整数！");
            return false;
        }
        if(!(/(^[1-9]\d*$)/.test(term_of))){
            layer.alert("有效期请填写整数！");
            return false;
        }

        var store=$("input[name='store[]']");
        var valarray=[];
        for(i=0;i<store.length;i++){

            if(store[i].checked){
                var val =store[i].value;
                valarray.push(val);

            }
        }
        console.log(333,valarray);
        if(valarray==""){
            layer.alert("请选择适用门店！");
            return false;
        }
        $('#forms').submit();

    })
</script>

</html>

